<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.css" rel="stylesheet" />
		<link href="../css/main.css" rel="stylesheet" />
		<link href="../css/login.css" rel="stylesheet" />
		<style type="text/css">
			.mui-bar-nav{
				    -webkit-box-shadow: none;
				    box-shadow: none;
			}
		</style>
	</head>

	<body >
		<header class="mui-bar mui-bar-nav">
			<div class="mui-margin-25"></div>
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">注册</h1>
		</header>
		<div class="mui-content" style="background: url(../img/heise_bg.jpg);background-size: 100% 100vh;background-repeat: no-repeat;">
			<!-- 组件 -->
			<div class="form-container" style="background-color: rgba(255,255,255,.2)">
				<div class="form-group-box">
					<div class="form-group-input" tabindex="1">
						<input type="text" placeholder="用户名" id="name"/>
					</div>
					<div class="form-group-input" tabindex="1">
						<input type="text" placeholder="账号" id="username"/>
					</div>
					<div class="form-group-input" tabindex="2">
						<input type="password" placeholder="密码" id="password"/>
					</div>
					<div class="form-group-input" tabindex="2">
						<input type="password" placeholder="确认密码" id="repass"/>
					</div>
					<div class="form-group-input" tabindex="2">
						<input type="text" placeholder="验证码" id="validaCode"/>
						<img data-flush src="${server.host}/coder/vc"   style="position: absolute ;right:76px;width: 70px;height:33px;z-index: 999;display: none;">
					</div>
					<div class="form-btn" id="regist-btn">
						<span>注册</span>
					</div>
				</div>
			</div>
		</div>
		
		
		<script src="../js/mui.js"></script>
		<script src="../js/jquery-3.1.1.min.js"></script>
		<script src="../js/promise.js"></script>
		<script src="../js/main.js" type="text/javascript">
			
		</script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function () {
				initDocumentHeight()
				const currentWebview = plus.webview.currentWebview();
				currentWebview.setStyle({
					softinputMode: "adjustResize"
				});
				document.getElementById("regist-btn").addEventListener("tap",function(){
					const _name =$("#name").val();
					const _username =$("#username").val();
					const _password = $("#password").val();
					const repass = $("#repass").val();
					const validaCode = $("#validaCode").val();

					
					if(!_name||_name==="" ){
						mui.alert("昵称不能为空","提示","确认",()=>{},"div")
						return;
					}
					if(!_username||_username==="" ){
						mui.alert("用户名不能为空","提示","确认",()=>{},"div")
						return;
					}
					if(!_password||_password==="" ){
						mui.alert("密码不能为空","提示","确认",()=>{},"div")
						return;
					}
					if(!repass||repass==="" ){
						mui.alert("确认密码不能为空","提示","确认",()=>{},"div")
						return;
					}
					if(!validaCode||validaCode==="" ){
						mui.alert("验证码不能为空","提示","确认",()=>{},"div")
						return;
					}
					if(_password !== repass){
						mui.alert("两次输入密码不一致","提示","确认",()=>{},"div")
						return;
					}
					
				plus.nativeUI.showWaiting("正在请求，请稍后...");
				_SERVER.user.regist({username:_username,password:_password,validaCode:validaCode,name:_name})
					.then(res=>{
						plus.nativeUI.closeWaiting();
						if(res.code === "200"){
							mui.toast("注册成功，即将跳转到登录页面")
							window.setTimeout(()=>{
								toBack();
							},3000);
						}else{
							mui.toast(res.msg)
						}
					})
				})
				
			})
			
			
			const toBack = function(){
				mui.back();
			}
		</script>
	</body>

</html>
